home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / video / fly8111-.000 / fly8111- / fly8 / obox.c < prev    next >
C/C++ Source or Header  |  1979-12-31  |  2KB  |  97 lines

  1. /* --------------------------------- obox.c --------------------------------- */
  2.  
  3. /* This is part of the flight simulator 'fly8'.
  4.  * Author: Eyal Lebedinsky (eyal@ise.canberra.edu.au).
  5. */
  6.  
  7. /* object O_BOX: only one side edge makes it more animated.
  8. */
  9.  
  10. #include "fly.h"
  11.  
  12.  
  13. static SHAPE shape_box = {
  14.     0,
  15.     0,
  16.     SH_G|SH_BEHIT,
  17.     50*1000L,    /* weight */
  18.     0        /* drag */
  19. };
  20.  
  21. LOCAL_FUNC int FAR
  22. create_box (OBJECT *p)
  23. {
  24.     int    i;
  25.  
  26.     p->da[Z] = VD360/5;
  27.     Mident (p->T);
  28.     if ((i = CS->device->colors) > 16)
  29.         i = 16;
  30.     p->color = Frand () % (i-1) + 1;
  31.     p->time = 5*60*TIMEPSEC;
  32.     p->flags |= F_VISIBLE;
  33.     p->damage = 3;
  34.     p->damaging = 1;
  35.     p->R[Z] = (Frand()%3000 + 1000)*(long)VONE;
  36.     do {
  37.         p->V[Y] = Frand()%(400*VONE) - 200*VONE;
  38.         p->V[X] = Frand()%(400*VONE) - 200*VONE;
  39.         p->speed = ihypot3d (p->V);
  40.     } while (p->speed < 120*VONE);
  41.     return (0);
  42. }
  43.  
  44. LOCAL_FUNC void FAR
  45. dynamics_box (OBJECT *p, int interval)
  46. {
  47.     if (p->flags & F_HIT) {
  48.         gen_dynamics (p, interval);
  49.         return;
  50.     }
  51.  
  52.     if (p->V[Z] > -250*VONE)
  53.         p->V[Z] -= TADJ (5*GACC);
  54.  
  55.     if (p->R[Z] < 0) {
  56.         p->R[Z] = 0;
  57.         p->V[Z] = -p->V[Z];
  58.         p->V[Z] -= p->V[Z]/16;
  59.     }
  60.  
  61.     if (p->R[X] > 5000L*VONE) {
  62.         p->V[X] = -p->V[X];
  63.         p->R[X] = 5000L*VONE;
  64.     } else if (p->R[X] < -5000L*VONE) {
  65.         p->V[X] = -p->V[X];
  66.         p->R[X] = -5000L*VONE;
  67.     }
  68.  
  69.     if (p->R[Y] > 5000L*VONE) {
  70.         p->V[Y] = -p->V[Y];
  71.         p->R[Y] = 5000L*VONE;
  72.     } else if (p->R[Y] < -5000L*VONE) {
  73.         p->V[Y] = -p->V[Y];
  74.         p->R[Y] = -5000L*VONE;
  75.     }
  76.     p->speed = ihypot3d (p->V);
  77.  
  78.     p->a[Z] += TADJ(p->da[Z])*VONE;
  79.     Mident (p->T);
  80.     fMrotz (p->T, p->sinz, p->cosz);
  81.  
  82.     object_update (p, interval);
  83. }
  84.  
  85. BODY FAR BoBox = {
  86.     0,
  87.     0,
  88.     "BOX",
  89.     &shape_box,
  90.     gen_read,
  91.     gen_term,
  92.     create_box,
  93.     gen_delete,
  94.     dynamics_box,
  95.     gen_hit
  96. };
  97.